﻿using System.ComponentModel;
using System.Windows.Controls;
using System.Windows.Input;
using AutoLoL.Entities;
using AutoLoL.Logic;
using AutoLoL.Logic.Masteries;
using AutoLoL.Logic.Factories;

namespace AutoLoL.Controls
{
    /// <summary>
    /// Interaction logic for MasteryControl.xaml
    /// </summary>
    public partial class MasteryControl : UserControl, INotifyPropertyChanged
    {
        private MasteryValue mastery;
        public MasteryValue Mastery
        {
            get { return mastery; }
            set
            {
                mastery = value;
                OnPropertyChanged("Mastery");
            }
        }

        public MasteryControl(MasteryValue mastery)
        {
            InitializeComponent();
            Mastery = mastery;
        }

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MasteryBuildManager manager = new MasteryBuildManager(mastery.MasteryTree.MasteryBuild, MasteryFactory.Instance, SummonerSpellFactory.Instance);
            manager.TryIncreaseValue(Mastery);
        }

        private void UserControl_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            MasteryBuildManager manager = new MasteryBuildManager(mastery.MasteryTree.MasteryBuild, MasteryFactory.Instance, SummonerSpellFactory.Instance);
            manager.TryDecreaseValue(Mastery);
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
